package com.lc.afbx.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.ListView;

import com.lc.afbx.BaseApplication;
import com.lc.afbx.R;
import com.lc.afbx.adapters.RecordAdapter;
import com.lc.afbx.conn.GetApiRecord;
import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.util.UtilToast;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/5/23.
 */
public class IntegralExchangeRecordActivity extends BaseActivity implements View.OnClickListener {


    private RecordAdapter adapter;
    private List<GetApiRecord.Data> lists = new ArrayList<>();
    private ListView integral_exchange_record_lv;

    private GetApiRecord getApiRecord = new GetApiRecord(new AsyCallBack<GetApiRecord.Info>() {
        @Override
        public void onSuccess(String toast, int type, GetApiRecord.Info info) throws Exception {

            lists.addAll(info.Data);

            adapter.notifyDataSetChanged();
        }

        @Override
        public void onFail(String toast, int type) throws Exception {

            UtilToast.show(context, toast);
        }
    });

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_integral_exchange_record);

        integral_exchange_record_lv = ((ListView) findViewById(R.id.integral_exchange_record_lv));
        integral_exchange_record_lv.setDividerHeight(20);

        integral_exchange_record_lv.setAdapter(adapter = new RecordAdapter(context, lists));

        getApiRecord.userid = BaseApplication.BasePreferences.readUserId();
        getApiRecord.execute(this);
    }


//    private void initView() {

//        hearder = getLayoutInflater().inflate(R.layout.header_duihuanjilu, null);
//        BaseApplication.ScaleScreenHelper.loadView((ViewGroup) hearder);
//        pullToRefreshListView = ((PullToRefreshListView) findViewById(R.id.duihuan_listview));
//        pullToRefreshListView.setScrollLoadEnabled(false);
//        pullToRefreshListView.setPullLoadEnabled(false);
//        pullToRefreshListView.setPullRefreshEnabled(false);
//
//        myListView = pullToRefreshListView.getRefreshableView();
//        myListView.addHeaderView(hearder, null, false);

//    }


    @Override
    public void onClick(View view) {

        switch (view.getId()) {

            case R.id.back:
                finish();
                return;


        }

    }

}
